<template>
	<view>
		<!-- #ifdef APP-PLUS -->
			<view class="imgtext" v-for="(item,index) in vipmember" :key="item.id">
					<image class="img1" :src="item.img" mode="widthFix" @click="gopayapp(item.id)"></image>
				
			</view>
		<!-- #endif -->
		<!-- #ifdef H5 -->
			<view class="imgtext" v-for="(item,index) in vipmember" :key="item.id">
				<image class="img1" :src="item.img" mode="widthFix" @click="gopay(item.id)"></image>
			
		</view>
		<!-- #endif -->
	
		
	</view>
</template>

<script>
	import $http from '@/common/api/request.js'
	export default {
		data() {
			return {
				money: 0,
				vipmember:[]
			};
		},
		methods: {
			//获取图片信息:
			getmenber(){
				$http.request({
					url: "/getmenberimg",
					method: "GET",
				}).then((res) => {
					if(res.code === 200){
						this.vipmember = res.message;
						
						this.vipmember = this.vipmember.map(item =>{
								item.img =  `https://zyc618.mynatapp.cc${item.img}`
							 return item
						})
						
					}
				}).catch(() => {
					uni.showToast({
						title: "失败.",
						icon: "none"
					})
				})
			},
			gopay(id) {
				if(id == 2){
					this.money = 138
					$http.request({
						url: "/memberpayment",
						method: "POST",
						header: {
							token: true
						},
						data: {
							money: this.money
						}
					}).then((res) => {
						//plus.runtime.openURL(res.paymentUrl)  //成功跳转url
						this.generateMyOrder(res.formData.fields[0].value)
						window.location.href = res.paymentUrl
						uni.navigateTo({
							url:'/pages/my/my'
						})
					}).catch(() => {
						uni.showToast({
							title: "失败.",
							icon: "none"
						})
					})
				}
				
			},
			gopayapp(id){
				if(id == 2){
					this.money = 138
					$http.request({
						url: "/memberpayment",
						method: "POST",
						header: {
							token: true
						},
						data: {
							money: this.money
						}
					}).then((res) => {
						plus.runtime.openURL(res.paymentUrl)  //成功跳转url
						this.generateMyOrder(res.formData.fields[0].value)
						
						uni.navigateTo({
							url:'/pages/my/my'
						})
					}).catch(() => {
						uni.showToast({
							title: "失败.",
							icon: "none"
						})
					})
				}
			},
			generateMyOrder(getMyOrderform) {
				$http.request({
					url: "/membergenerateMyOrder",
					method: "POST",
					header: {
						token: true
					},
					data: {
						MyOrderform: getMyOrderform
					}
				}).then((res) => {

				}).catch(() => {
					uni.showToast({
						title: "请求失败",
						icon: "none"
					})
				})
			},
		},
		onLoad() {
			this.getmenber();
		}

	}
</script>

<style lang="scss">
	.imgtext {
		position: relative;

		.title {

			color: #fff;
			background-color: #ff007a;
			font-size: 40rpx;
			padding: 5rpx;
			position: absolute;
			left: 197rpx;
			top: 500rpx;
			z-index: 999;
		}

		.title2 {

			color: #fff;
			background-color: #ff007a;
			font-size: 36rpx;
			position: absolute;
			padding: 10rpx;
			right: 205rpx;
			top: 500rpx;
			z-index: 999;
		}
	}

	.img1 {
		width: 100%;
	}

	.img2 {
		width: 100%;
	}

	.img3 {
		width: 100%;
	}
</style>